package com.student.liu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.student.liu.entity.GoodsSpec;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 商品规格 Mapper
 */
@Mapper
public interface IGoodsSpecMapper extends BaseMapper<GoodsSpec> {

    @Update("update goods_spec set inventory=inventory-${count} where id=${id}")
    Integer updateCount(@Param("id") Integer id, @Param("count") Integer count);

    @Select("SELECT id,goods_id,name,price,inventory FROM goods_spec WHERE goods_id=${goodsId}")
    GoodsSpec getGoodsSpecById(@Param("id") Integer goodsId);
}
